home *** CD-ROM | disk | FTP | other *** search
Wrap
class Game { var mcRef; var nNeedInitialLevelPause; var oWinPopUp; var oULLosePopUp; var oMenuPopUp; var oHelpPopUp; var oConfirmPopUp; var oObjectivesPopUp; var oTransition; var oTransitionMiniGameStart; var oTransitionMiniGameEnd; var oPlayerStatus; var oGameTimer; var bTimeOverTriggered; var sPlayMode; var oLevel; var nObjectivesCloseTimer; var oMiniGame; var sCurrentSection; var oTargetLevelData; var nNewLevelTargetRow; var nConfirmContext; var oLevelToDelete; var oLevelSelector; var bTestingUserLevel; var nPlayLevelType; var sDeleteLevelName; var nMoonStonesCatched; var nMiniStonesCatched; var nAwardedNPs; var oTestLevel; var sTargetSection; var oMusicGameGround; var oMusicGameSky; var nGameStatus; var nLatestHelpPage; var oLevelEditor; var nCurrentShownScore; static var oCtrl; static var SECTION_LEVEL_SELECT_STORY = "LevelSelectStory"; static var SECTION_LEVEL_SELECT_USER = "LevelSelectUser"; static var SECTION_GAME = "Game"; static var SECTION_EDITOR = "Edit"; static var CONFIRM_CONTEXT_DELETE_LEVEL = 1; static var CONFIRM_CONTEXT_QUIT_GAME = 2; static var GAME_STATUS_SIDESCROLLER = 1; static var GAME_STATUS_MINIGAME = 2; static var DEPTH_SIDESCROLLER = 150; static var DEPTH_MINIGAME = 250; static var HUD_POINTS_UPDATE_RATE = 120; static var STAGE_WIDTH = 600; static var STAGE_HEIGHT = 300; static var aNP_BY_SCORE = [{nMin:-Infinity,nMax:99999,nPts:1},{nMin:100000,nMax:124999,nPts:2},{nMin:125000,nMax:149999,nPts:3},{nMin:150000,nMax:174999,nPts:5},{nMin:175000,nMax:Infinity,nPts:10}]; function Game(__mcRef, __bStoryMode) { this.mcRef = __mcRef; Game.oCtrl = this; this.nNeedInitialLevelPause = -1; this.oWinPopUp = new Library.BasicPopUp(this.mcRef.mcPopups.mcWin); this.oWinPopUp.Listener = this; Main.Instance.doAddListener(this.oWinPopUp); this.oULLosePopUp = new Library.BasicPopUp(this.mcRef.mcPopups.mcULLose); this.oULLosePopUp.Listener = this; Main.Instance.doAddListener(this.oULLosePopUp); this.oMenuPopUp = new Library.BasicPopUp(this.mcRef.mcPopups.mcMenu); this.oMenuPopUp.Listener = this; Main.Instance.doAddListener(this.oMenuPopUp); this.oHelpPopUp = new Library.BasicPopUp(this.mcRef.mcPopups.mcHelp); this.oHelpPopUp.Listener = this; Main.Instance.doAddListener(this.oHelpPopUp); this.oConfirmPopUp = new Library.BasicPopUp(this.mcRef.mcPopups.mcConfirm); this.oConfirmPopUp.Listener = this; Main.Instance.doAddListener(this.oConfirmPopUp); this.oObjectivesPopUp = new Library.BasicPopUp(this.mcRef.mcPopups.mcObjectives); this.oObjectivesPopUp.Listener = this; Main.Instance.doAddListener(this.oObjectivesPopUp); this.oTransition = new Library.Transition(this.mcRef.mcTransition); this.oTransition.Listener = this; Main.Instance.doAddListener(this.oTransition); this.oTransitionMiniGameStart = new Library.Transition(this.mcRef.mcTransitionMGStart); this.oTransitionMiniGameStart.Listener = this; Main.Instance.doAddListener(this.oTransitionMiniGameStart); this.oTransitionMiniGameEnd = new Library.Transition(this.mcRef.mcTransitionMGEnd); this.oTransitionMiniGameEnd.Listener = this; Main.Instance.doAddListener(this.oTransitionMiniGameEnd); this.oPlayerStatus = new PlayerStatus(); this.oGameTimer = new Library.Utils.Timer(); this.oGameTimer.FrameRate = Main.FRAME_RATE; this.oGameTimer.Method = Library.Utils.Timer.TIMER_COUNT_DOWN; Main.Instance.doAddListener(this); this.bTimeOverTriggered = false; if(__bStoryMode) { this.sPlayMode = Game.SECTION_LEVEL_SELECT_STORY; } else { this.sPlayMode = Game.SECTION_LEVEL_SELECT_USER; } this.doSetSection(this.sPlayMode); } static function get Instance() { return Game.oCtrl; } function doEnterFrame() { super.doEnterFrame(); if(this.nNeedInitialLevelPause != -1) { this.nNeedInitialLevelPause = this.nNeedInitialLevelPause + 1; if(this.nNeedInitialLevelPause >= 3) { this.nNeedInitialLevelPause = -1; this.oLevel.doPause(); } } if(this.nObjectivesCloseTimer > 0) { this.nObjectivesCloseTimer = this.nObjectivesCloseTimer - 1; if(this.nObjectivesCloseTimer == 0) { this.oObjectivesPopUp.doClose(); this.oLevel.doResume(); } } else if(!this.oLevel.bPaused || !this.oMiniGame.bPaused) { this.oGameTimer.doEnterFrame(); } if(this.sCurrentSection == Game.SECTION_GAME) { this.doWatchTime(); this.doUpdateHudPoints(); } } function doCreateNewLevel(__nRowNum) { delete this.oTargetLevelData; this.nNewLevelTargetRow = __nRowNum; this.doTransitionTo(Game.SECTION_EDITOR); } function onConfirmAnswer(__bAnswer) { if(__bAnswer) { if(this.nConfirmContext == Game.CONFIRM_CONTEXT_DELETE_LEVEL) { this.Status.doDeleteUserLevel(this.oLevelToDelete); this.oLevelSelector.onLevelDeleted(); } else if(this.nConfirmContext == Game.CONFIRM_CONTEXT_QUIT_GAME) { if(this.bTestingUserLevel) { this.doTransitionTo(Game.SECTION_EDITOR); this.oConfirmPopUp.doClose(); this.oMenuPopUp.doClose(); } else if(this.nPlayLevelType == BaseLevelData.LEVEL_TYPE_STORY) { Main.Instance.onPlayerLose(Main.LOSE_REASON_QUIT); } else { if(this.bTestingUserLevel) { this.doEditLevel(this.oTargetLevelData); } else { this.doTransitionTo(Game.SECTION_LEVEL_SELECT_USER); } this.oMenuPopUp.doClose(); } } } this.oConfirmPopUp.doClose(); delete this.oLevelToDelete; } function doAskDeleteLevel(__oLevel) { this.sDeleteLevelName = __oLevel.LevelName; this.oLevelToDelete = __oLevel; this.nConfirmContext = Game.CONFIRM_CONTEXT_DELETE_LEVEL; this.oConfirmPopUp.doOpen(); } function doEditLevel(__oLevel) { this.oTargetLevelData = __oLevel; this.doTransitionTo(Game.SECTION_EDITOR); } function doExitEditor() { this.doTransitionTo(Game.SECTION_LEVEL_SELECT_USER); } function doTestLevel(__oLevel) { this.bTestingUserLevel = true; this.oTargetLevelData = __oLevel; this.doTransitionTo(Game.SECTION_GAME); } function doStartLevel(__oLevel, _nLevelType) { this.bTestingUserLevel = false; this.nPlayLevelType = _nLevelType; this.oTargetLevelData = __oLevel; this.doTransitionTo(Game.SECTION_GAME); } function onTakReachEnd() { if(this.nMoonStonesCatched >= this.oTargetLevelData.RequiredMS) { this.doLevelEnd(true); } else { this.doLevelEnd(false,Main.LOSE_REASON_MOONSTONES); } } function doLevelEnd(__bWon, __nLoseReason) { this.oGameTimer.doStopTimer(); this.oLevel.doPause(); this.oMiniGame.doPause(); if(__bWon) { var _loc4_ = new BaseLevelData(); _loc4_.Completed = true; _loc4_.RequiredMS = this.oTargetLevelData.RequiredMS; _loc4_.TimeAllowed = this.oTargetLevelData.TimeAllowed; _loc4_.TimeTaken = this.oTargetLevelData.TimeAllowed - this.oGameTimer.Time; _loc4_.CollectedMS = this.nMoonStonesCatched; _loc4_.MiniStones = this.nMiniStonesCatched; if(_loc4_.Score > this.oTargetLevelData.Score) { this.oTargetLevelData.Completed = true; this.oTargetLevelData.TimeTaken = this.oTargetLevelData.TimeAllowed - this.oGameTimer.Time; this.oTargetLevelData.CollectedMS = this.nMoonStonesCatched; this.oTargetLevelData.MiniStones = this.nMiniStonesCatched; this.oTargetLevelData.doSave(); } if(this.nPlayLevelType == BaseLevelData.LEVEL_TYPE_STORY) { var _loc7_ = this.oTargetLevelData.LevelNumber; if(_loc7_ < this.Status.getLevelQuantity(this.LevelType)) { var _loc6_ = this.Status.getLevelData(this.LevelType,_loc7_ + 1); _loc6_.Locked = false; _loc6_.doSave(); } var _loc18_ = BaseLevelData.POINTS_BASE; var _loc13_ = this.oTargetLevelData.RequiredMS; var _loc9_ = BaseLevelData.POINTS_PER_MS_BASE; var _loc14_ = _loc13_ * _loc9_; var _loc15_ = this.nMoonStonesCatched - this.oTargetLevelData.RequiredMS; var _loc11_ = BaseLevelData.POINTS_PER_MS_OVER; var _loc10_ = _loc15_ * _loc11_; var _loc17_ = this.nMiniStonesCatched; var _loc19_ = BaseLevelData.POINTS_PER_MINISTONES; var _loc8_ = _loc17_ * _loc19_; var _loc12_ = this.oGameTimer.Time; var _loc16_ = Math.floor(_loc12_ * BaseLevelData.POINTS_PER_MILLISECOND_REMAINING); var _loc3_ = _loc18_ + _loc14_ + _loc10_ + _loc8_ + _loc16_; if(Main.Instance.HSM.getIsLoggedIn()) { this.nAwardedNPs = 0; for(var _loc5_ in Game.aNP_BY_SCORE) { var _loc2_ = Game.aNP_BY_SCORE[_loc5_]; if(_loc2_.nMin <= _loc3_ && _loc2_.nMax >= _loc3_) { this.nAwardedNPs = _loc2_.nPts; break; } } Main.Instance.StageRoot.awardPoints(this.nAwardedNPs); } } this.oWinPopUp.doOpen(); } else if(this.sPlayMode == Game.SECTION_LEVEL_SELECT_STORY) { Main.Instance.onPlayerLose(__nLoseReason); } else { this.oULLosePopUp.doOpen(); } } function doProgressToNextLevel() { var _loc2_ = this.oTargetLevelData.LevelNumber; this.oTargetLevelData = this.oPlayerStatus.getLevelData(this.LevelType,_loc2_ + 1); this.doTransitionTo(Game.SECTION_GAME); } function doShowWinScreen() { Main.Instance.onPlayerWin(); } function doShowLevelMap() { this.doTransitionTo(this.sPlayMode); } function onLostMoonstone() { this.nMoonStonesCatched = this.nMoonStonesCatched - 1; this.nMoonStonesCatched = Math.max(0,this.nMoonStonesCatched); this.oTestLevel.CollectedMS = this.nMoonStonesCatched; this.mcRef.mcScreen.mcHud.txtMoonStones.text = Library.Utils.Tools.getFormatedNumber(this.nMoonStonesCatched,3); } function onCatchMoonstone() { Library.Sound.SoundManager.isSoundPlaying("Moonstone.mp3").oSound.doStop(); Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Moonstone.mp3"); this.nMoonStonesCatched = this.nMoonStonesCatched + 1; this.oTestLevel.CollectedMS = this.nMoonStonesCatched; this.mcRef.mcScreen.mcHud.txtMoonStones.text = Library.Utils.Tools.getFormatedNumber(this.nMoonStonesCatched,3); } function onCatchMiniStone() { Library.Sound.SoundManager.isSoundPlaying("Ministone.mp3").oSound.doStop(); Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Ministone.mp3"); this.nMiniStonesCatched = this.nMiniStonesCatched + 1; this.oTestLevel.MiniStones = this.nMiniStonesCatched; } function onFeatherCatch() { this.oLevel.doPause(); Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Wind_Transition_In.mp3"); this.oTransitionMiniGameStart.doStart(); } function doMinigameEnd() { Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Wind_Transition_Out.mp3"); this.oTransitionMiniGameEnd.doStart(); } function onTransitionEvent(__nEvent, __oTransition) { switch(__nEvent) { case Library.Transition.TRANSITION_SCREEN_COVERED: if(__oTransition == this.oTransition) { this.doUnloadSection(this.sCurrentSection); this.doSetSection(this.sTargetSection); Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"transition_out.mp3",60); } else { this.doToggleGameStatus(); } break; case Library.Transition.TRANSITION_COMPLETE: } } function onPopUpEvent(__nEvent, __oPopUp) { if(__nEvent === Library.BasicPopUp.NEED_UPDATE) { switch(__oPopUp) { case this.oHelpPopUp: this.doUpdateHelpPopUp(); break; case this.oULLosePopUp: this.doUpdateULLosePopUp(); break; case this.oWinPopUp: this.doUpdateWinPopUp(); break; case this.oMenuPopUp: this.doUpdateMenuPopUp(); break; case this.oConfirmPopUp: this.doUpdateConfirmPopUp(); break; case this.oObjectivesPopUp: this.doUpdateObjectivesPopUp(); } } } function doSoundEvent(__nEvent, __oSound) { if(__nEvent === Library.Sound.SoundManager.EVENT_SOUND_COMPLETE) { if(__oSound == this.oMusicGameGround) { delete this.oMusicGameGround; } else if(__oSound == this.oMusicGameSky) { delete this.oMusicGameSky; } } } function doStartMusic() { if(this.oMusicGameSky == undefined) { this.oMusicGameSky = Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_MUSIC,"Game_Sky.wav",0,999999); this.oMusicGameSky.doAddListener(this); this.oMusicGameSky.setFadeRate(8); } if(this.oMusicGameGround == undefined) { this.oMusicGameGround = Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_MUSIC,"Game_Ground.wav",0,999999); this.oMusicGameGround.doAddListener(this); this.oMusicGameGround.setFadeRate(8); } } function doStopMusic() { if(this.oMusicGameSky != undefined) { this.oMusicGameSky.setFadeRate(8); this.oMusicGameSky.doFadeTo(0); } if(this.oMusicGameGround != undefined) { this.oMusicGameGround.setFadeRate(8); this.oMusicGameGround.doFadeTo(0); } } function doStartMusicGround() { this.doStartMusic(); this.oMusicGameSky.setFadeRate(8); this.oMusicGameGround.setFadeRate(8); this.oMusicGameSky.doFadeTo(0,false); this.oMusicGameGround.doFadeTo(100); } function doStartMusicSky() { this.doStartMusic(); this.oMusicGameSky.setFadeRate(2); this.oMusicGameGround.setFadeRate(2); this.oMusicGameGround.doFadeTo(0,false); this.oMusicGameSky.doFadeTo(100); } function doToggleMuteFor(__sCategory) { if(Library.Sound.SoundManager.isCategoryMuted(__sCategory)) { Library.Sound.SoundManager.doUnMuteCategory(__sCategory); } else { Library.Sound.SoundManager.doMuteCategory(__sCategory); } this.doUpdateMenuSoundGroups(); } function doShowMenu() { if(this.oObjectivesPopUp.CurrentState == "Hidden") { this.oLevel.doPause(); this.oMiniGame.doPause(); this.oMenuPopUp.doOpen(); this.oGameTimer.doStopTimer(); } } function doCloseMenu() { if(this.nGameStatus == Game.GAME_STATUS_SIDESCROLLER) { this.oLevel.doResume(); } else { this.oMiniGame.doResume(); } this.oMenuPopUp.doClose(); this.oGameTimer.doStartTimer(); } function doBackToTitle() { Main.Instance.onBackToTitle(); } function doQuitGame() { this.nConfirmContext = Game.CONFIRM_CONTEXT_QUIT_GAME; this.oConfirmPopUp.doOpen(); } function doCloseHelp() { this.oHelpPopUp.doClose(); delete this.nLatestHelpPage; } function doShowHelp() { this.oHelpPopUp.doOpen(); } function doInstructionPageChange(__nChange) { this.oHelpPopUp.Ref.gotoAndStop(this.oHelpPopUp.Ref._currentframe + __nChange); this.nLatestHelpPage = this.oHelpPopUp.Ref._currentframe; this.doUpdateHelpPopUp(); } function doDestroy() { this.oMiniGame.doDestroy(); this.oLevel.doDestroy(); delete this.oMiniGame; delete this.oLevel; Main.Instance.doRemoveListener(this); delete this.oGameTimer; this.oMenuPopUp.doHide(); this.oWinPopUp.doHide(); this.doStopMusic(); Main.Instance.doStartPackMusic(); } function get MSQty() { return this.nMoonStonesCatched; } function get Score() { var _loc4_ = 0; var _loc5_ = undefined; if(this.sPlayMode == Game.SECTION_LEVEL_SELECT_STORY) { var _loc2_ = 1; while(_loc2_ <= Game.Instance.Status.getLevelQuantity(BaseLevelData.LEVEL_TYPE_STORY)) { var _loc3_ = Game.Instance.Status.getLevelData(BaseLevelData.LEVEL_TYPE_STORY,_loc2_); _loc4_ += _loc3_.Score; _loc2_ = _loc2_ + 1; } } else if(this.sPlayMode == Game.SECTION_LEVEL_SELECT_USER) { _loc4_ = this.oTargetLevelData.Score; } return _loc4_; } function get LevelType() { var _loc2_ = undefined; if(this.sPlayMode == Game.SECTION_LEVEL_SELECT_STORY) { _loc2_ = BaseLevelData.LEVEL_TYPE_STORY; } else if(this.sPlayMode == Game.SECTION_LEVEL_SELECT_USER) { _loc2_ = BaseLevelData.LEVEL_TYPE_USER; } return _loc2_; } function get Editor() { return this.oLevelEditor; } function get Status() { return this.oPlayerStatus; } function doUpdateHudPoints() { this.nCurrentShownScore = Library.Utils.MoreMath.getReachNum(this.nCurrentShownScore,this.oTestLevel.Score - BaseLevelData.POINTS_BASE,Game.HUD_POINTS_UPDATE_RATE); this.mcRef.mcScreen.mcHud.txtScore.text = Library.Utils.Tools.getFormatedNumber(this.nCurrentShownScore,6); } function doWatchTime() { this.mcRef.mcScreen.mcHud.txtTime.text = Library.Utils.Tools.getFormatedTime(this.oGameTimer.Time,false); if(this.oGameTimer.Time <= 0 && !this.bTimeOverTriggered) { this.bTimeOverTriggered = true; this.doLevelEnd(false,Main.LOSE_REASON_TIMEOUT); } } function doToggleGameStatus() { if(this.nGameStatus == Game.GAME_STATUS_SIDESCROLLER) { this.mcRef.mcScreen.mcSS._visible = false; this.mcRef.mcScreen.mcMG._visible = true; this.doCreateMiniGame(); this.doStartMusicSky(); } else { this.mcRef.mcScreen.mcSS._visible = true; this.mcRef.mcScreen.mcMG._visible = false; this.oMiniGame.doDestroy(); this.oLevel.doResumeFromMiniGame(); this.doStartMusicGround(); this.nGameStatus = Game.GAME_STATUS_SIDESCROLLER; } } function doUpdateHelpPopUp() { if(this.nLatestHelpPage != undefined) { this.oHelpPopUp.Ref.gotoAndStop(this.nLatestHelpPage); } else { this.oHelpPopUp.Ref.stop(); } this.oHelpPopUp.Ref.btnPlay.onRelease = Library.Utils.Delegate.create(this,this.doCloseHelp); this.oHelpPopUp.Ref.btnPlay.onRelease = Library.Utils.Delegate.create(this,this.doCloseHelp); this.oHelpPopUp.Ref.btnNext.onRelease = Library.Utils.Delegate.create(this,this.doInstructionPageChange,1); this.oHelpPopUp.Ref.btnBack.onRelease = Library.Utils.Delegate.create(this,this.doInstructionPageChange,-1); } function doUpdateObjectivesPopUp() { this.oObjectivesPopUp.Ref.txtMoonstones.text = this.oTargetLevelData.RequiredMS; this.oObjectivesPopUp.Ref.txtTime.text = Library.Utils.Tools.getFormatedTime(this.oTargetLevelData.TimeAllowed,false); } function doUpdateConfirmPopUp() { if(this.nConfirmContext == Game.CONFIRM_CONTEXT_DELETE_LEVEL) { this.oConfirmPopUp.Ref.mcText.gotoAndStop(1); this.oConfirmPopUp.Ref.mcText.txtName.text = this.sDeleteLevelName; } else if(this.nConfirmContext == Game.CONFIRM_CONTEXT_QUIT_GAME) { this.oConfirmPopUp.Ref.mcText.gotoAndStop(2); } this.oConfirmPopUp.Ref.btnYes.onRelease = Library.Utils.Delegate.create(this,this.onConfirmAnswer,true); this.oConfirmPopUp.Ref.btnNo.onRelease = Library.Utils.Delegate.create(this,this.onConfirmAnswer,false); } function doUpdateMenuPopUp() { this.oMenuPopUp.Ref.btnResume.onRelease = Library.Utils.Delegate.create(this,this.doCloseMenu); this.oMenuPopUp.Ref.btnHelp.onRelease = Library.Utils.Delegate.create(this,this.doShowHelp); this.oMenuPopUp.Ref.btnQuit.onRelease = Library.Utils.Delegate.create(this,this.doQuitGame); this.doUpdateMenuSoundGroups(); } function doUpdateMenuSoundGroups() { var _loc2_ = "On"; if(Library.Sound.SoundManager.isCategoryMuted(Main.SOUND_CAT_SOUND)) { _loc2_ = "Off"; } var _loc3_ = "On"; if(Library.Sound.SoundManager.isCategoryMuted(Main.SOUND_CAT_MUSIC)) { _loc3_ = "Off"; } this.oMenuPopUp.Ref.mcSoundToggle.gotoAndStop(_loc2_); this.oMenuPopUp.Ref.mcMusicToggle.gotoAndStop(_loc3_); this.oMenuPopUp.Ref.mcSoundToggle.btnToggle.onRelease = Library.Utils.Delegate.create(this,this.doToggleMuteFor,Main.SOUND_CAT_SOUND); this.oMenuPopUp.Ref.mcMusicToggle.btnToggle.onRelease = Library.Utils.Delegate.create(this,this.doToggleMuteFor,Main.SOUND_CAT_MUSIC); } function doUpdateULLosePopUp() { if(this.bTestingUserLevel) { this.oULLosePopUp.Ref.mcButtons.gotoAndStop(1); this.oULLosePopUp.Ref.mcButtons.btnReturn.onRelease = Library.Utils.Delegate.create(this,this.doEditLevel,this.oTargetLevelData); } else { this.oULLosePopUp.Ref.mcButtons.gotoAndStop(2); this.oULLosePopUp.Ref.mcButtons.btnReturn.onRelease = Library.Utils.Delegate.create(this,this.doTransitionTo,Game.SECTION_LEVEL_SELECT_USER); } } function doUpdateWinPopUp() { var _loc11_ = undefined; if(this.sPlayMode == Game.SECTION_LEVEL_SELECT_STORY) { _loc11_ = BaseLevelData.LEVEL_TYPE_STORY; } else if(this.sPlayMode == Game.SECTION_LEVEL_SELECT_USER) { _loc11_ = BaseLevelData.LEVEL_TYPE_USER; } var _loc15_ = this.oTargetLevelData.LevelNumber; var _loc17_ = this.oPlayerStatus.getLevelQuantity(_loc11_); if(this.nPlayLevelType == BaseLevelData.LEVEL_TYPE_STORY) { if(_loc15_ >= _loc17_) { this.oWinPopUp.Ref.mcButtons.gotoAndStop("EndLevel"); this.oWinPopUp.Ref.mcButtons.btnContinue.onRelease = Library.Utils.Delegate.create(this,this.doShowWinScreen); } else { this.oWinPopUp.Ref.mcButtons.gotoAndStop("NormalPlay"); this.oWinPopUp.Ref.mcButtons.btnLevel.onRelease = Library.Utils.Delegate.create(this,this.doShowLevelMap); this.oWinPopUp.Ref.mcButtons.btnNext.onRelease = Library.Utils.Delegate.create(this,this.doProgressToNextLevel); } } else { this.oWinPopUp.Ref.mcButtons.gotoAndStop("Testing"); this.oWinPopUp.Ref.mcButtons.btnReturn.onRelease = Library.Utils.Delegate.create(this,this.doEditLevel,this.oTargetLevelData); } var _loc13_ = BaseLevelData.POINTS_BASE; var _loc7_ = this.oTargetLevelData.RequiredMS; var _loc3_ = BaseLevelData.POINTS_PER_MS_BASE; var _loc8_ = _loc7_ * _loc3_; var _loc9_ = this.nMoonStonesCatched - this.oTargetLevelData.RequiredMS; var _loc5_ = BaseLevelData.POINTS_PER_MS_OVER; var _loc4_ = _loc9_ * _loc5_; var _loc12_ = this.nMiniStonesCatched; var _loc14_ = BaseLevelData.POINTS_PER_MINISTONES; var _loc2_ = _loc12_ * _loc14_; var _loc6_ = this.oGameTimer.Time; var _loc10_ = Math.floor(_loc6_ * BaseLevelData.POINTS_PER_MILLISECOND_REMAINING); var _loc16_ = _loc13_ + _loc8_ + _loc4_ + _loc2_ + _loc10_; this.oWinPopUp.Ref.txtCompleteBonus.text = Library.Utils.Tools.getFormatedNumber(_loc13_); this.oWinPopUp.Ref.txtReqMSNum.text = Library.Utils.Tools.getFormatedNumber(_loc7_,2); this.oWinPopUp.Ref.txtReqMSPts.text = Library.Utils.Tools.getFormatedNumber(_loc3_); this.oWinPopUp.Ref.txtReqMSTotal.text = Library.Utils.Tools.getFormatedNumber(_loc8_); this.oWinPopUp.Ref.txtAddMSNum.text = Library.Utils.Tools.getFormatedNumber(_loc9_,2); this.oWinPopUp.Ref.txtAddMSPts.text = Library.Utils.Tools.getFormatedNumber(_loc5_); this.oWinPopUp.Ref.txtAddMSTotal.text = Library.Utils.Tools.getFormatedNumber(_loc4_); this.oWinPopUp.Ref.txtGemsNum.text = Library.Utils.Tools.getFormatedNumber(_loc12_,2); this.oWinPopUp.Ref.txtGemsPts.text = Library.Utils.Tools.getFormatedNumber(_loc14_); this.oWinPopUp.Ref.txtGemsTotal.text = Library.Utils.Tools.getFormatedNumber(_loc2_); this.oWinPopUp.Ref.txtTime.text = Library.Utils.Tools.getFormatedTime(_loc6_,true); this.oWinPopUp.Ref.txtTimeTotal.text = Library.Utils.Tools.getFormatedNumber(_loc10_); this.oWinPopUp.Ref.txtScoreFinal.text = Library.Utils.Tools.getFormatedNumber(_loc16_); if(Main.Instance.HSM.getIsLoggedIn() && this.sPlayMode == Game.SECTION_LEVEL_SELECT_STORY) { this.oWinPopUp.Ref.mcNP.txtPts.text = this.nAwardedNPs; } else { this.oWinPopUp.Ref.mcNP._visible = false; } } function doCreateLevelEditor() { var _loc2_ = false; if(this.oTargetLevelData != undefined) { _loc2_ = true; } var _loc3_ = new LevelEditor(this.mcRef.mcScreen,_loc2_,this.oTargetLevelData,this.nNewLevelTargetRow); } function doCreateLevelSelector(__nLevelType) { this.oLevelSelector = new LevelSelector(this.mcRef.mcScreen,__nLevelType); this.mcRef.mcScreen.btnQuit.onRelease = Library.Utils.Delegate.create(this,this.doBackToTitle); } function doCreateMiniGame() { this.nGameStatus = Game.GAME_STATUS_MINIGAME; this.oMiniGame = new MiniGameManager(this.mcRef.mcScreen.mcMG); } function doCreateLevel() { this.nGameStatus = Game.GAME_STATUS_SIDESCROLLER; this.nMoonStonesCatched = 0; this.nMiniStonesCatched = 0; this.nCurrentShownScore = 0; this.mcRef.mcScreen.mcHud.txtMoonStones.text = Library.Utils.Tools.getFormatedNumber(this.nMoonStonesCatched,3); this.mcRef.mcScreen.mcHud.mcInvincibility._visible = Main.Instance.CodeBoxManager.Invincible; this.bTimeOverTriggered = false; this.oLevel = new LevelManager(this.mcRef.mcScreen.mcSS,this.oTargetLevelData); this.mcRef.mcScreen.mcHud.btnMenu.onRelease = Library.Utils.Delegate.create(this,this.doShowMenu); this.nNeedInitialLevelPause = 0; this.oTestLevel = new BaseLevelData(); this.oTestLevel.Completed = true; this.oTestLevel.RequiredMS = this.oTargetLevelData.RequiredMS; this.oTestLevel.CollectedMS = 0; this.oTestLevel.MiniStones = 0; this.oTestLevel.TimeAllowed = this.oTargetLevelData.TimeAllowed; this.oTestLevel.TimeTaken = this.oTargetLevelData.TimeAllowed; this.oGameTimer.setTime(this.oTargetLevelData.TimeAllowed + 150); this.oGameTimer.doStartTimer(); this.oObjectivesPopUp.doOpen(); this.nObjectivesCloseTimer = 90; this.doUpdateHudPoints(); Main.Instance.doStopPackMusic(); this.doStartMusicGround(); } function doUnloadEditor() { this.oLevelEditor.doDestroy(); delete this.oLevelEditor; } function doUnloadSelector() { this.oLevelSelector.doDestroy(); delete this.oLevelSelector; } function doUnloadLevel() { this.oWinPopUp.doHide(); this.oULLosePopUp.doHide(); this.oLevel.doRemoveListener(this.oGameTimer); this.oLevel.doDestroy(); delete this.oLevel; this.doStopMusic(); Main.Instance.doStartPackMusic(); } function doSetSection(__sSection) { this.sCurrentSection = __sSection; this.mcRef.gotoAndStop(this.sCurrentSection); switch(this.sCurrentSection) { case Game.SECTION_LEVEL_SELECT_STORY: this.doCreateLevelSelector(BaseLevelData.LEVEL_TYPE_STORY); break; case Game.SECTION_LEVEL_SELECT_USER: this.doCreateLevelSelector(BaseLevelData.LEVEL_TYPE_USER); break; case Game.SECTION_GAME: this.doCreateLevel(); break; case Game.SECTION_EDITOR: this.doCreateLevelEditor(); } } function doUnloadSection(__sSection) { switch(__sSection) { case Game.SECTION_LEVEL_SELECT_STORY: case Game.SECTION_LEVEL_SELECT_USER: this.doUnloadSelector(); break; case Game.SECTION_EDITOR: this.doUnloadEditor(); break; case Game.SECTION_GAME: this.doUnloadLevel(); } } function doTransitionTo(__sSection) { this.sTargetSection = __sSection; this.oTransition.doStart(); Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"transition_in.mp3",60); } }